package org.shj.thread;

import org.shj.thread.util.Util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

/**
 * @author Shen Huang Jian
 * @date 2020-05-11 10:05
 */
public class ThreadTest {
    private CachedThreadPool pool = new CachedThreadPool();

    public static void main(String[] args){
        List<String> list = new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        List<String> list2 = list.stream().filter(a -> "c".equals(a)).collect(Collectors.toList());
        System.out.println(list2.size());
//        Map<String,String> map = new ConcurrentHashMap<>();
//        System.out.println(map.putIfAbsent("aa", "a"));
//        System.out.println(map.putIfAbsent("aa", "a"));
//        System.out.println(map.putIfAbsent("aa", "a"));
//        ThreadTest te = new ThreadTest();
//        te.test();
    }

    public void test(){
        Future<String> future = pool.getCachedThreadPool().submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                return "aaa";
            }
        });

        for(int i = 0 ; i < 10; i++){
            try {
                System.out.println(future.get());
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }

}
